import { Window } from "../../../component/window/Window";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { CopyResultBg } from "../common/displayBg/CopyResultBg";
import { GBitmap } from "../../../../com/mui/controls/GBitmap";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { ItemShowRenderer } from "../ItemShowRenderer";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { SDominionMyResult } from "../../../../Message/Public/SDominionMyResult";
import { DomWarCopyRewardsConfig } from "../../resource/DomWarCopyRewardsConfig";
import { ConstConfig } from "../../resource/ConstConfig";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
type int = number;
//class DominionWarResultWin
    
    export  class DominionWarResultWin extends Window
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(652, 351);
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc3=NaN;
            super.createChildren();
            var loc1=new GTextFormat(FontUtil.EmbedNumberName, 24, 15788607);
            var loc2=new Object /* flash.text.TextFormat */(null, 15, GlobalStyle.color2Uint);
            this._copyResultBg = new CopyResultBg();
            this.addChild(this._copyResultBg);
            this._titleBmp = new GBitmap();
            this.addChild(this._titleBmp);
            this._titleBmp.x = 174;
            this._titleBmp.y = 5;
            this._rankBtn = ObjCreate.createGButton(Language.getString(32048), 470, 255, 60, 25, this);
            this._rankBtn.addEventListener(flash.events.MouseEvent.CLICK, this.clickHandler);
            this._leaveBtn = ObjCreate.createGButton(Language.getString(41665), 550, 255, 45, 25, this);
            this._leaveBtn.addEventListener(flash.events.MouseEvent.CLICK, this.clickHandler);
            loc3 = 15;
            this._rankTextBmp = new GBitmap();
            this._rankTextBmp.x = 350;
            this._rankTextBmp.y = 5;
            this.addChild(this._rankTextBmp);
            this._tfTextRank = ObjCreate.createTextField("", 409, 5, 53, 20, this, GlobalStyle.textFormat6);
            this._rankTxt = ObjCreate.createGTextField("", 455, loc3, 60, 25, this, loc1);
            this._rankTxt.autoSize = "left";
            this._rankTxt.embedFonts = true;
            this._incomeBmp = new GBitmap();
            this.addChild(this._incomeBmp);
            this._incomeBmp.x = 195;
            this._incomeBmp.y = 72;
            this._allIncomneTxt = ObjCreate.createGTextField("", 265, 98, 60, 25, this, loc2);
            this._resultLogoBmp = new GBitmap();
            this.addChild(this._resultLogoBmp);
            this._resultLogoBmp.x = 365;
            this._resultLogoBmp.y = 88;
            this._percentTxt = ObjCreate.createGTextField("", 433, 105, 60, 25, this, loc2);
            this._allIncomneTxt.autoSize = "left";
            this._percentTxt.autoSize = "left";
            this._killRwBmp = new GBitmap();
            this.addChild(this._killRwBmp);
            this._killRwBmp.x = this._incomeBmp.x;
            this._killRwBmp.y = 163;
            this._killIncomeTxt = ObjCreate.createGTextField("", this._allIncomneTxt.x, 188, 60, 25, this, loc2);
            this._damgeRwBmp = new GBitmap();
            this.addChild(this._damgeRwBmp);
            this._damgeRwBmp.x = this._resultLogoBmp.x;
            this._damgeRwBmp.y = this._killRwBmp.y;
            this._damegIncomeTxt = ObjCreate.createGTextField("", this._percentTxt.x, this._killIncomeTxt.y, 60, 25, this, loc2);
            this._killIncomeTxt.autoSize = "left";
            this._damegIncomeTxt.autoSize = "left";
            this._warRewardsBmp = new GBitmap();
            this.addChild(this._warRewardsBmp);
            this._warRewardsBmp.x = 195;
            this._warRewardsBmp.y = 248;
            var loc4=[];
            this._rewarsList = this.getTileList(this._warRewardsBmp.x + 88, this._warRewardsBmp.y, loc4.length * 43, 40, ItemShowRenderer, 3, 0, 1, loc4.length, 40, 40);
            LoaderHelp.addResCallBack(ResFileConst.dominionWarResult, this.onLoaded);
            return;
        }

        /* internal  */getTileList(arg1: number, arg2: number, arg3: number, arg4: number, arg5: Class, arg6: number=0, arg7: number=0, arg8: int=3, arg9: int=3, arg10: number=50, arg11: number=50): GTileList
        {
            var loc1;
            (loc1 = new GTileList()).columnCount = arg9;
            loc1.rowCount = arg8;
            loc1.columnWidth = arg10;
            loc1.rowHeight = arg11;
            loc1.horizontalGap = arg6;
            loc1.verticalGap = arg7;
            loc1.setSize(arg3, arg4);
            loc1.setStyle("cellRenderer", arg5);
            loc1.setStyle("skin", new Object /* flash.display.Sprite */());
            loc1.x = arg1;
            loc1.y = arg2;
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */onLoaded(): void
        {
            var loc1=null;
            this._isloaded = true;
            this._rankTextBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.domWar_resultRank);
            this._incomeBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.domWar_income);
            this._killRwBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.domWar_killRewards);
            this._titleBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.domWar_resultTitle);
            this._warRewardsBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.domWar_resultReward);
            this._damgeRwBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.domWar_damgeRewards);
            if (this.sInfo) 
            {
                if (this.sInfo.win) 
                {
                    loc1 = ImagesConst.domWar_winLogo;
                }
                else 
                {
                    loc1 = ImagesConst.domWar_loseLogo;
                }
                this._resultLogoBmp.bitmapData = GlobalClass.getBitmapData(loc1);
            }
            return;
        }

        protected clickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.currentTarget;
            switch (loc1) 
            {
                case this._leaveBtn:
                {
                    this.hide();
                    Dispatcher.dispatchEvent(new DataEvent(EventName.CopyQuitCopy));
                    break;
                }
                case this._rankBtn:
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.OnOpenDomWarRank));
                    break;
                }
            }
            return;
        }

        public /* override */ update(arg1: Object, ... rest): void
        {
            var loc5=null;
            var loc6=null;
            var loc7=null;
            super.update(arg1, rest);
            this.sInfo = arg1 as SDominionMyResult;
            var loc1=DomWarCopyRewardsConfig.instance;
            this._allIncomneTxt.text = this.sInfo.coinNum.toString();
            var loc2=loc1.getRewardsByKill(this.sInfo.killPlayer);
            this._killIncomeTxt.text = loc2.toString();
            var loc3=loc1.getRewardsByRank(this.sInfo.rank);
            this._damegIncomeTxt.text = loc3.toString();
            var loc4=ConstConfig.instance.getObjectByName("DominionKillPlayerN");
            if (this.sInfo.win) 
            {
                loc5 = Language.getString(41685);
                loc6 = loc4.constValue.toString();
                loc7 = ImagesConst.domWar_winLogo;
            }
            else 
            {
                loc5 = Language.getString(41686);
                loc6 = loc4.constValueEx.toString();
                loc7 = ImagesConst.domWar_loseLogo;
            }
            this._rankTxt.text = this.sInfo.rank.toString();
            this._tfTextRank.text = loc5;
            this._percentTxt.text = loc6;
            if (this._isloaded) 
            {
                this._resultLogoBmp.bitmapData = GlobalClass.getBitmapData(loc7);
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            super.dispose(arg1);
            this._leaveBtn.removeEventListener(flash.events.MouseEvent.CLICK, this.clickHandler);
            this._rankBtn.removeEventListener(flash.events.MouseEvent.CLICK, this.clickHandler);
            return;
        }

        /* internal */ /* var */_copyResultBg: CopyResultBg;

        /* internal */ /* var */_leaveBtn: GButton;

        /* internal */ /* var */_rankBtn: GButton;

        /* internal */ /* var */_rankTxt: GTextFiled;

        /* internal */ /* var */_allIncomneTxt: GTextFiled;

        /* internal */ /* var */_percentTxt: GTextFiled;

        /* internal */ /* var */_killIncomeTxt: GTextFiled;

        /* internal */ /* var */_damegIncomeTxt: GTextFiled;

        /* internal */ /* var */_tfTextRank: GTextFiled;

        /* internal */ /* var */_titleBmp: GBitmap;

        /* internal */ /* var */_rankTextBmp: GBitmap;

        /* internal */ /* var */_incomeBmp: GBitmap;

        /* internal */ /* var */_damgeRwBmp: GBitmap;

        /* internal */ /* var */_killRwBmp: GBitmap;

        /* internal */ /* var */_resultLogoBmp: GBitmap;

        /* internal */ /* var */_warRewardsBmp: GBitmap;

        /* internal */ /* var */_isloaded: Boolean;

        /* internal */ /* var */_isUpdate: Boolean;

        /* internal */ /* var */_rewarsList: GTileList;

        /* internal */ /* var */sInfo: SDominionMyResult;
    }
